package com.anjubao.parking.municipal.common.utils;

import java.util.HashMap;

import com.anjubao.parking.municipal.common.entity.BaseEntity;
import com.baomidou.mybatisplus.core.toolkit.LambdaUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;

/**
 * 参数map
 * 
 * @author Atom.zyu
 *
 */
public class ParamsMap<T> extends HashMap<String, Object> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 4990989001198023943L;

	public ParamsMap() {
	}

	public ParamsMap(SFunction<T, ?> key, Object value) {
		String resolveFieldName = StringUtils.resolveFieldName(LambdaUtils.resolve(key).getImplMethodName());
		this.put(resolveFieldName, value);
	}

	public ParamsMap(String key, Object value) {
		this.put(key, value);
	}

	public ParamsMap<T> put(String key, Object value) {
		super.put(key, value);
		return this;
	}

	public static void main(String[] args) {
		ParamsMap<BaseEntity> p = new ParamsMap<BaseEntity>(BaseEntity::getCreateTime, "aaa");
		System.out.println(U.json(p));
	}
}
